package everything;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class HumanAgent extends Agent {

	public HumanAgent(String name, String color, int x, int y, WorldMap map) {
		super(name, color, x, y, map);
		_type = "human";
	}

	@Override
	public void makeMove() {
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			//TODO make reading not waiting to ENTER
			if (_onIce){
				move("DOESNT MATTER");
			} else {
				int input = in.read();	//TODO input checking
				System.out.println("Location: x = " + _xLocation + " y = " + _yLocation);
				switch (input){
				case '8':
					if(_map.isMovementBlocked(_xLocation - 1, _yLocation))
						setOrientation("NORTH");
					else move("NORTH");
					break;
				case '2':
					if(_map.isMovementBlocked(_xLocation + 1, _yLocation))
						setOrientation("SOUTH");
					else move("SOUTH");
					break;
				case '4':
					if(_map.isMovementBlocked(_xLocation , _yLocation - 1))
						setOrientation("WEST");
					else move("WEST");
					break;
				case '6':
					if(_map.isMovementBlocked(_xLocation , _yLocation + 1))
						setOrientation("EAST");
					else move("EAST");
					break;
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public boolean isKilling(int x, int y, WorldMap map) {
		return false;
	}

}
